<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/iconfont.css">
<link rel="stylesheet" type="text/css" href="css/iconfont1.css">
<title>companyinfo</title>
<jsp:include page="base.jsp"></jsp:include>
<style type="text/css">
table.hovertable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.hovertable th {
	background-color:#c3dde0;
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #a9c6c9;
}
table.hovertable tr {
	background-color:#d4e3e5;
}
table.hovertable td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #a9c6c9;
}
.input01{
	margin-left:20px;
}
.tf:hover{
cursor:hand;
}   

</style>
</head>
<body bgcolor="	#E8E8E8">
<table>
<tr>
</tr>
</table>
<table  id='#table2' style="margin-top:-20px">
<tr>
<td align=right><form id="formname">400号码：<input name="callee_number"/>&nbsp;&nbsp;公司名称：<input name="company_name"/>&nbsp;&nbsp;联系人：<input name="contactor"/><br/><br/>手机号码：<input name="mobile"/>&nbsp;&nbsp;邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：<input name="mail"/>&nbsp;&nbsp;代理商：<input name="agency"/></form></td>
<td align=left><button id="sele">查询</button><br><br><button class="balance">查询欠费</button></td>
<td><button id="reg" style="margin-left:-30px">注册</button><br><br><button class="balance">查询告警</button></td>
<td><br><br><button class="balance" style="margin-top:2px">查询正常</button></td>
<td><button id="export" style="margin-left:-160px">导出Excel</button></td>
</tr>
</table>                          
<table style="margin-top:-30px;margin-left:-20px" class="table hovertable" width="1365px"></table>
<div class="pagination-holder clearfix">
<div id="light-pagination" class="pagination"></div>
</div>
<script type="text/javascript">
	var callee_number;
	var pageNum=12;// 每页显示的数据个数
	var paging=1;// 当前页初始为1
	window.onload=function(){
		//页面首次加载载入的公司信息列表
		$.ajax({
			url:'user/sele',
			type:'get',
			data:'',
			dataType:'json',
			success:function(data){
				if(data.flag){
						getDate(data.obj);			
				}else{
					layer.alert(data.msg);
				}
			}	
		});
	};
	//查询公司信息
		$('#sele').click(function(){
		paging=1;
		$.ajax({
			url:'user/sele',
			type:'get',
			data:$("#formname").serialize(),
			dataType:'json',
			success:function(data){
				if(data.flag){
					getDate(data.obj);
				}else{
					layer.alert(data.msg);
				}
			}
		});
	});
	//按查询条件导出Excel
	$('#export').click(function(){
		$.ajax({
			url:'excel/outExcel',
			type:'get',
			data:$("#formname").serialize(),
			dataType:'json',
			success:function(data){
					layer.alert(data.msg);
				}
			
		});

	});
		// 删除用户
		$('#delete01').on('click',function(){ 			
			var ids=[];
			var a=$('.input01:checked');
			console.info(a);
			if(a.length>0){
				layer.confirm('确认删除？',{btn:['是','否']},
						function(){
							for(var i=0;i<a.length;i++){
								ids.push(a[i].value);
								console.info(a[i]);
							}
							$.ajax({
								url:'user/del',
								type:'get',
								data:'ids='+ids,//+'&name='+$("[name=name]").val()
								dataType:'json',
								success:function(data){
									if(data.flag){
										getDate(data.obj);
									}else{
										layer.alert(data.msg);
									}
								}
							});
							layer.msg('删除成功',{icon:1});
							
						},function(){
						
							return;
						});
			}else{
				return;
			}
		});
	$(".balance").click(function(){
		paging=1;
		$.ajax({
			url:'user/selebalance',
			type:'get',
			data:"name="+$(this).html(),
			dataType:'json',
			success:function(data){
				if(data.flag){
					getDate(data.obj);
				}else{
					layer.alert(data.msg);
				}
			}
		});	
	});
	//停机接口
	$(".table").on('click',"tr .tf .icon-tingji",function(){
	console.info($(this).attr("value"));
		$.ajax({
			url:'single/stop',
			type:'get',
			data:"number="+$(this).attr("value"),
			dataType:'json',
			success:function(data){
				layer.alert(data.msg);
			}
		});		
	});
	//复机接口
	$(".table").on('click',"tr .tf .icon-fuji",function(){
		$.ajax({
			url:'single/reset',
			type:'get',
			data:"number="+$(this).prev().attr("value"),
			dataType:'json',
			success:function(data){
				layer.alert(data.msg);
			}
		});		
	});
	
	$(".table").on('mouseover',"tr .tf .icon-fuji,.icon-tingji",function(){
		$(this).css("cursor","pointer");
	});
	
	function getDate(data){
		datagrid=data;//传给datagrid
		for(var a=0;a<datagrid.length;a++){
			datagrid[a].create_time = new Date(datagrid[a].create_time).toLocaleString();
			datagrid[a].update_time = new Date(datagrid[a].update_time).toLocaleString();
			datagrid[a].start_date = new Date(datagrid[a].start_date).toLocaleDateString();
			datagrid[a].expire_date = new Date(datagrid[a].expire_date).toLocaleDateString();
		}
	var total=datagrid.length;		
	$(".table").empty();
	$(".table").append("<tr><td width=10px></td><td class='d' align='center'>400号码</td><td class='d' align='center'>公司</td><td class='d' align='center'>联系人</td><td  class='d' align='center'>手机号</td><td class='d' align='center'>邮箱</td><td class='d' align='center'>余额</td><td class='d'>指导价</td><td class='d' align='center'>类别</td><td class='d' align='center'>代理商</td></tr>");
		if(datagrid.length<pageNum*paging){
			for(var i=(paging-1)*pageNum;i<datagrid.length;i++){
				$(".table").append("<tr onmouseover=this.style.backgroundColor='#ffff66'; onmouseout=this.style.backgroundColor='#d4e3e5'; class='tr1'><td width=20px><input class='input01' type=checkbox  value='"+datagrid[i].callee_number+"'></td><td  class='d'>"+datagrid[i].callee_number+"</td><td class='d'><a href='user/"+datagrid[i].callee_number+"'>"+datagrid[i].company_name+"</a></td><td>"+datagrid[i].contactor+"</td><td width=20px>"+datagrid[i].mobile+"</td><td class='d'>"+datagrid[i].mail+"</td><td class='d'>"+datagrid[i].balance+"</td><td class='d'>"+datagrid[i].guide_price+"</td><td class='d'>"+datagrid[i].category+"</td><td class='d'>"+datagrid[i].agency+"</td></tr>");
	   			}
		}else{
			for(var i=(paging-1)*pageNum;i<pageNum;i++){
				$(".table").append("<tr onmouseover=this.style.backgroundColor='#ffff66'; onmouseout=this.style.backgroundColor='#d4e3e5'; class='tr1'><td width=20px><input class='input01' type=checkbox  value='"+datagrid[i].callee_number+"'></td><td class='d'>"+datagrid[i].callee_number+"</td><td class='d'><a href='user/"+datagrid[i].callee_number+"'>"+datagrid[i].company_name+"</a></td><td>"+datagrid[i].contactor+"</td><td width=20px>"+datagrid[i].mobile+"</td><td class='d'>"+datagrid[i].mail+"</td><td class='d'>"+datagrid[i].balance+"</td><td class='d'>"+datagrid[i].guide_price+"</td><td class='d'>"+datagrid[i].category+"</td><td class='d'>"+datagrid[i].agency+"</td></tr>");//<td style='cursor:hand' align='center' class='d tf'></td>
   			}
	   	}
		$('#light-pagination').pagination({
	  		pages: Math.ceil(total/pageNum),
	  		displayedPages:5,
	  		onPageClick:function(pageNumber,event){
				paging=pageNumber;
				$(".table").empty();
				$(".table").append("");
				$(".table").append("<tr><td width=10px></td><td class='d'>400号码</td><td class='d'>公司</td><td class='d'>联系人</td><td class='d'>手机号</td><td class='d'>邮箱</td><td class='d'>余额</td><td class='d'>指导价</td><td class='d'>类别</td><td class='d'>代理商</td></tr>");
				if(datagrid.length<paging*pageNum){
					for(var i=(paging-1)*pageNum;i<datagrid.length;i++){
						$(".table").append("<tr onmouseover=this.style.backgroundColor='#ffff66'; onmouseout=this.style.backgroundColor='#d4e3e5'; class='tr1'><td width=20px><input class='input01' type=checkbox  value='"+datagrid[i].callee_number+"'></td><td class='d'>"+datagrid[i].callee_number+"</td><td class='d'><a href='user/"+datagrid[i].callee_number+"'>"+datagrid[i].company_name+"</a></td><td>"+datagrid[i].contactor+"</td><td width=20px>"+datagrid[i].mobile+"</td><td class='d'>"+datagrid[i].mail+"</td><td class='d'>"+datagrid[i].balance+"</td><td class='d'>"+datagrid[i].guide_price+"</td><td class='d'>"+datagrid[i].category+"</td><td class='d'>"+datagrid[i].agency+"</td></tr>");
		   			}	
				}else{
					for(var i=(paging-1)*pageNum;i<pageNum*paging;i++){
						$(".table").append("<tr onmouseover=this.style.backgroundColor='#ffff66'; onmouseout=this.style.backgroundColor='#d4e3e5'; class='tr1'><td width=20px><input class='input01' type=checkbox  value='"+datagrid[i].callee_number+"'></td><td class='d'>"+datagrid[i].callee_number+"</td><td class='d'><a href='user/"+datagrid[i].callee_number+"'>"+datagrid[i].company_name+"</a></td><td>"+datagrid[i].contactor+"</td><td width=20px>"+datagrid[i].mobile+"</td><td class='d'>"+datagrid[i].mail+"</td><td class='d'>"+datagrid[i].balance+"</td><td class='d'>"+datagrid[i].guide_price+"</td><td class='d'>"+datagrid[i].category+"</td><td class='d'>"+datagrid[i].agency+"</td></tr>");	   	
						}
					}
			}
		});
	}
</script>	
</body>
</html>